<?php
class Application_Model_Filter_AgentPaySearch {
    //快速搜索
    public $quick;
    //开始时间
    public $starttime;
    //结束时间
    public $endtime;
    //状态
    public $status;
    
    function getSearchFileds() {
        $where = array();
        $and = "";
        if($this->quick){
            $quick = trim($this->quick);
            $where["( "] = 1;
            $or = " and ";
            $user = Application_Model_User::bystore($quick);
            if ($user) {
                $where[$or . ' memberId = '] = $user->id;
                $or = " or ";
            }else{
                $where[$or . ' memberId = '] = "";
                $or = " or ";
            }

            $where[$or . " id = "] = $quick;
            $or = " or ";            
            
            $where[") and "] = "1=1";
            $and = ' and ';
        }
        if ($this->starttime != '') {
            $where[$and  . ' dateCreated >='] = $this->starttime . " 00:00:00";
            $and = ' and ';
        }
        if ($this->endtime != '') {
            $where[$and  . ' dateCreated <='] = $this->endtime . " 23:59:59";
            $and = ' and ';
        }
        if($this->status !== null && $this->status !== ""){
            $where[$and . " status = "] = $this->status;
            $and = " and ";
        }
        if($and){
            $where[' and memberId != '] = '';
        }else{
           $where[' memberId != '] = ''; 
        }
        return $where;
    }
}
